#import time
#import dailyspents.util as util
#import os
#import cherrypy
#from os.path import join
<html>

#include join(util.HTMLPATH, 'common', 'head.html')

<body>
	<div id="site">
		#include join(util.HTMLPATH, 'common', 'top.html')
		#include join(util.HTMLPATH, 'common', 'menu.html')
		<div id="content">
		  <!-------------------- LEFT SIDE ------------------------->
		  <div id="left">
		    <div class="tl"><div class="tr">
			    spents
			</div></div>
			
			#include join(util.HTMLPATH, 'common', 'errorMessages.html')
			
			<!------------------ SPENTS RESULTS AND DELETE FORM ------------>
				#if $spents != None and len($spents)>0:
					<form action="/main/deleteSpent" name="spentsForm" method="POST">
					
					#include join(util.HTMLPATH, 'common', 'spentsActions.html')
					
					<table class="result">
					
						#set total = 0
						#for n, spent in enumerate($spents):
							#set colors = ['#eeeeec', 'white']
							
							<tr bgcolor="$colors[n%2]">
								<td><input type="checkbox" name="spentsCheckBox" value="$spent.id"/></td>
								<td onclick="document.location='/spent?page=edit&id='+$spent.id;">
									#if $spent.category != None:
										<font color="#4e9a06">$spent.category.name</font>
									#end if
								</td>
								<td onclick="document.location='/spent?page=edit&id='+$spent.id;">
									#if $spent.payment != None:
										<font color="red">$spent.payment.name</font>
									#end if
								</td>
								<td nowrap="nowrap" onclick="document.location='/spent?page=edit&id='+$spent.id;">
									#if $spent.date != None:
										#try:
										<small>$spent.date.strftime('%d %b %y')</small>
										#except:
											$time.strftime('%d %b %y', $spent.date)
										#end try
									#end if
								</td>
                                                                <td onclick="document.location='/spent?page=edit&id='+$spent.id;">
                                                                    #if $spent.local != None:
                                                                        <small>$spent.local.name</small>
                                                                    #end if
                                                                </td>
								<td onclick="document.location='/spent?page=edit&id='+$spent.id;">$spent.description</td>
								<td onclick="document.location='/spent?page=edit&id='+$spent.id;">
									$cherrypy.session['user'].settings.currency 
									$spent.value
								</td>
								
								#set total += $spent.value
								
							</tr>
							
						#end for
						
					</table>
					
					<span style="padding: 2px 10px;">
        					$cherrypy.session['user'].settings.currency
        					$total
        				</span>
					
					#include join(util.HTMLPATH, 'common', 'spentsActions.html')
					
					</form>
					
				#else:
					You have no spent.
				#end if
			<!-- END OF SPENTS RESULTS AND DELETE FORM -->
		  </div>
		  <!-- END OF LEFTSIDE -->
		  <!-- RIGHTSIDE -->
		  <div id="right">
				<!------------------- STATISTICS RESULTS ----------------------
				#if $spents != None and len($spents)>0:
				<div style="padding: 7px; border: 1px solid; margin: 10px;
        			    background: url('/static/images/menu-buttom-bg.png')">
        				<span style="padding: 2px 10px;">
        					$cherrypy.session['user'].settings.currency
        					$total
        				</span>
        			</div>
				#end if -->
				<!-- END OF STATISTICS RESULTS -->
			  	#include join(util.HTMLPATH, 'common', 'categories.html')
				#include join(util.HTMLPATH, 'common', 'locals.html')
				#include join(util.HTMLPATH, 'common', 'payments.html')
				
		  </div>
		</div>
		#include join(util.HTMLPATH, 'common', 'bottom.html')
	</div>
</body>

</html>
